package com.java.action;

import java.util.List;

import com.java.service.IDeptService;
import com.opensymphony.xwork2.ActionSupport;
import com.training.pojo.chengshu.UDept;

public class DeptListAction extends ActionSupport {
	private static final long serialVersionUID = 1L;

	private IDeptService deptService;
	
	
	private List<UDept> deptlist;
	private static final Integer PAGECOUNT = 5;
	private Integer page=1;
	private Integer endpage;
	private Integer rowCount;

	public String execute(){
		
		rowCount = deptService.countDept();
		endpage =((rowCount%PAGECOUNT)==0?(rowCount/PAGECOUNT):(rowCount/PAGECOUNT + 1));
		
		if(page < 0){
			page = 1;
		}
		if(page > endpage){
			page = endpage;
		}
		int start =((page - 1)*PAGECOUNT );
		deptlist = deptService.deptList(start);
		System.out.println("///////////");
		return "success";
	}

	
	public List<UDept> getDeptlist() {
		return deptlist;
	}

	public void setDeptlist(List<UDept> deptlist) {
		this.deptlist = deptlist;
	}

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getEndpage() {
		return endpage;
	}

	public void setEndpage(Integer endpage) {
		this.endpage = endpage;
	}

	public Integer getRowCount() {
		return rowCount;
	}

	public void setRowCount(Integer rowCount) {
		this.rowCount = rowCount;
	}


	public IDeptService getDeptService() {
		return deptService;
	}


	public void setDeptService(IDeptService deptService) {
		this.deptService = deptService;
	}
	
	
	
}
